<?php

Load::lib('gdata');
//Zend_Loader::loadClass('Zend_Gdata_YouTube');
Zend_Loader::loadClass('Zend_Gdata_Photos');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
/* require_once 'Zend/Loader.php';
  Zend_Loader::loadClass('Zend_Gdata_Photos');
  Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
  Zend_Loader::loadClass('Zend_Gdata_AuthSub'); */

class Picasa {

    var $gp;

    public function __construct() {
        $username = "picasa@descargatump3.com";
        $pass = "9700947f";
        $serviceName = Zend_Gdata_Photos::AUTH_SERVICE_NAME;
        $client = Zend_Gdata_ClientLogin::getHttpClient($username, $pass, $serviceName);
        $this->gp = new Zend_Gdata_Photos($client, "Google-DevelopersGuide-1.0");
    }

    public function albunes() {
        try {
            $userFeed = $this->gp->getUserFeed("default");
            return $userFeed;
            /* foreach ($userFeed as $userEntry) {
              echo $userEntry->title->text . "<br />\n";
              } */
        } catch (Zend_Gdata_App_HttpException $e) {
            $error = "Error: " . $e->getMessage() . "<br />\n";
            if ($e->getResponse() != null) {
                $error .= "Body: <br />\n" . $e->getResponse()->getBody() .
                        "<br />\n";
            }
            return $error;
            // In new versions of Zend Framework, you also have the option
            // to print out the request that was made.  As the request
            // includes Auth credentials, it's not advised to print out
            // this data unless doing debugging
            // echo "Request: <br />\n" . $e->getRequest() . "<br />\n";
        } catch (Zend_Gdata_App_Exception $e) {
            return "Error: " . $e->getMessage() . "<br />\n";
        }
    }

    public function imagenes($idAlbun) {
        // Creates a Zend_Gdata_Photos_AlbumQuery
        $query = $this->gp->newAlbumQuery();
        $query->setUser("default");
        $query->setAlbumId($idAlbun);
        try {
            $albumFeed = $this->gp->getAlbumFeed($query);
            return $albumFeed;
        } catch (Zend_Gdata_App_Exception $e) {
            return "Error: " . $e->getMessage() . "<br />\n";
        }
    }

}

?>
